#pragma once

#include <OceanScene>
#include <FFTOceanSurface>
#include "transformable.h"
#include <osg\TextureCubeMap>

namespace osg
{
	class TextureCubeMap;
}

namespace VrDataCore
{
	class CoreBase::ActorBase;
	class Ocean: public CoreBase::Transformable
	{
	public:
		struct OceanParameter
		{
			osg::ref_ptr<osg::TextureCubeMap>	_tex;
			QString					_cubemapDirs;
			osg::Vec4f				_lightColors;
			osg::Vec4f				_fogColors;
			osg::Vec3f				_underwaterAttenuations;
			osg::Vec4f				_underwaterDiffuse;
			osg::Vec3f				_sunPositions;
			osg::Vec4f				_sunDiffuse;
			osg::Vec4f				_waterFogColors;
		};
		Ocean(CoreBase::ActorBase* owneractor,const QString& name = "Ocean");

		void setEnvironmentParameter(osg::TextureCubeMap* texture,const osg::Vec4& lightcolor,const osg::Vec4& fogcolors,
			const osg::Vec4& waterfogcolors,const osg::Vec4& underwaterdiffuse,const osg::Vec3& underwaterattenuations
			,const osg::Vec3& sunpositions,const osg::Vec4& sundiffuse);

		virtual bool addChild(CoreBase::Drawable* child);
		void setSize(const osg::Vec2& size);
		virtual void addedToScene(CoreBase::Scene* scene);
		void getOceanSurfaceHeight(osg::Vec3& pos);
		void setFoamHeight(int h);
		int getFoamHeight();
		void setWaveScale(int h);
		int getWaveScale();
		void setEnvironmentColor(const osg::Vec4& color);
		void setLightPosition(const osg::Vec3& pos);
	protected:
		void build( osg::TextureCubeMap* texture,const osg::Vec4& lightcolor,const osg::Vec4& fogcolors,
			const osg::Vec4& waterfogcolors,const osg::Vec4& underwaterdiffuse,const osg::Vec3& underwaterattenuations
			,const osg::Vec3& sunpositions,const osg::Vec4& sundiffuse);
		~Ocean();
		osg::ref_ptr<osg::Group>							_root;
		osg::ref_ptr<osgOcean::FFTOceanSurface>				_oceanSurface;
		osg::TextureCubeMap*								_textureCubeMap;
		osg::ref_ptr<osgOcean::OceanScene>					_oceanScene;
		osg::LightSource*									_lightSource;
	private:
		osg::Vec2f		_windDirection;
		osg::Vec2f		_size;
		float			_windSpeed;
		float			_depth;
		float			_reflectionDamping;
		float			_waveScaleBase;
		bool			_isChoppy;
		float			_choppyFactor;
		float			_crestFoamHeight;
		bool			_inScene;
		int				_foamHeightScale;
		int				_waveScale;
		OceanParameter	_parameter;
	};
}